package com.example.test.socket;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @program: programme
 * @description: 创建全局Map存放现已连接服务器
 * @author: qiu bo yang
 * @create: 2020-10-09 09:57
 **/
public class SocketPool {
    private static final ConcurrentHashMap<String, ClientSocket> ONLINE_SOCKET_MAP = new ConcurrentHashMap<>();


    public static void add(ClientSocket clientSocket) {
        if (clientSocket != null && !clientSocket.getKey().isEmpty())
            ONLINE_SOCKET_MAP.put(clientSocket.getKey(), clientSocket);
    }

    public static void remove(String key) {
        if (!key.isEmpty())
            ONLINE_SOCKET_MAP.remove(key);

    }
}
